home *** CD-ROM | disk | FTP | other *** search
/ com!online 2005 May / com_0505_1.iso / opensource / top10 / amc_install.exe / {app} / Scripts / Carteles-Metropoli (ES).ifs < prev    next >
Encoding:
Text File  |  2004-03-25  |  7.4 KB  |  225 lines

  1. // GETINFO SCRIPTING
  2. // Carteles-Metropoli v1.0 by micmic.ifs
  3.  
  4. (***************************************************
  5.  *  Author: micmic (micmic@dieznet.com)            *
  6.  *  Script for the importation of pictures from    *
  7.  *  carteles.metropoliglobal.com                   *
  8.  *                                                 *
  9.  *  For use with Ant Movie Catalog 3.4.0           *
  10.  *  www.ant.be.tf/moviecatalog ╖╖╖ www.buypin.com  *
  11.  *                                                 *
  12.  *  The source code of the script can be used in   *
  13.  *  another program only if full credits to        *
  14.  *  script author and a link to Ant Movie Catalog  *
  15.  *  website are given in the About box or in       *
  16.  *  the documentation of the program               *
  17.  ***************************************************)
  18.  
  19. program micmic;
  20. var
  21.   MovieName: string;
  22. const
  23.   Base = 'http://carteles.metropoliglobal.com/';
  24.   BaseURL = 'http://carteles.metropoliglobal.com/4resultados.php?titulo=';
  25.   BaseURL2 = '&director=&interpretes=&Submit=Buscar';
  26.  
  27. function FindLine(Pattern: string; List: TStringList; StartAt: Integer): Integer;
  28. var
  29.   i: Integer;
  30. begin
  31.   result := -1;
  32.   if StartAt < 0 then
  33.     StartAt := 0;
  34.   for i := StartAt to List.Count-1 do
  35.     if Pos(Pattern, List.GetString(i)) <> 0 then
  36.     begin
  37.       result := i;
  38.       Break;
  39.     end;
  40. end;
  41.  
  42. procedure AnalyzePage(Address: string);
  43. var
  44.   Page: TStringList;
  45.   LineNr: Integer;
  46.   PosIni, PosFin: Integer;
  47.   Line, SubLine: string;
  48.   Title, DirURL: string;
  49.   txtTemp: string;
  50. begin
  51.   Page := TStringList.Create;
  52.   Page.Text := GetPage(Address);
  53.   if Pos('No se han encontrado resultados', Page.Text) > 0 then
  54.   begin
  55.     ShowMessage('No se ha encontrado ning·n artφculo por tφtulo.');
  56.   end else
  57.   begin
  58.     PickTreeClear;
  59.     PickTreeAdd('Resultados de la b·squeda para "' + MovieName + '":', '');
  60.    
  61.     // buscamos los resultados
  62.     LineNr := 0;
  63.  
  64.     while LineNr < Page.Count do
  65.     begin
  66.       SubLine := Page.GetString(LineNr);
  67.       txtTemp := '<td width="92%"><font size="2" face="Arial, Helvetica, sans-serif"><strong><a href="';
  68.       PosIni := pos(txtTemp, SubLine);
  69.       if PosIni > 0 then
  70.       begin
  71.         SubLine := Copy(SubLine, PosIni + Length(txtTemp), Length(SubLine));
  72.        
  73.         txtTemp := '">';
  74.         PosFin := pos(txtTemp, SubLine);
  75.         DirURL := Base + Copy(SubLine, 1, PosFin - 1);
  76.        
  77.         SubLine := Copy(SubLine, PosFin + Length(txtTemp), Length(SubLine));
  78.         txtTemp := '</a>';
  79.         PosFin := pos(txtTemp, SubLine);
  80.         Title := Copy(SubLine, 1, PosFin - 1);
  81.  
  82.         //ShowMessage(Title + '-->' + DirURL);
  83.         PickTreeAdd(Title, DirURL);
  84.       end;
  85.       LineNr := LineNr + 1;
  86.     end;
  87.  
  88.     Page.Free;
  89.     if PickTreeExec(Address) then
  90.       AnalyzeMoviePage(Address);
  91.   end;
  92. end;
  93.  
  94.  
  95. procedure AnalyzeMoviePage(Address: string);
  96. var
  97.   Page: TStringList;
  98.   PosIni, PosFin: Integer;
  99.   dirBase: string;
  100.   txtTemp: string;
  101.   txtAux: string;
  102.   campo, valor: string;
  103.   LineNr: Integer;
  104.   Line, SubLine: string;
  105.   Imagen: string;
  106.   Comentarios: string;
  107. begin
  108.   //ShowMessage(Address);
  109.  
  110.   SetField(fieldURL, Address);
  111.  
  112.   Page := TStringList.Create;
  113.   Page.Text := StringReplace(GetPage(Address), '<br>', #13#10);
  114.  
  115.   // buscamos los campos
  116.   Comentarios := '';
  117.   Imagen := '';
  118.   LineNr := 0;
  119.   while LineNr < Page.Count do
  120.   begin
  121.     SubLine := Page.GetString(LineNr);
  122.    
  123.     txtTemp := '<title>';
  124.     PosIni := pos(txtTemp, SubLine);
  125.     if PosIni > 0 then
  126.     begin
  127.       txtAux := Copy(SubLine, PosIni + Length(txtTemp), Length(SubLine));
  128.       PosFin := pos('</title>', txtAux);
  129.       campo := Copy(txtAux, 1, PosFin - 1);
  130.       if campo <> '' then SetField(fieldTranslatedTitle, campo);
  131.     end;
  132.    
  133.     txtTemp := '<td width="68%" valign="TOP" bgcolor="#F5F5F5"><font size="1" face="Verdana, Arial, Helvetica, sans-serif">';
  134.     PosIni := pos(txtTemp, SubLine);
  135.     if PosIni > 0 then
  136.     begin
  137.       txtAux := Copy(SubLine, PosIni + Length(txtTemp), Length(SubLine));
  138.       PosFin := pos('</font></td>', txtAux);
  139.       campo := Copy(txtAux, 1, PosFin - 1);
  140.       if campo <> '' then SetField(fieldOriginalTitle, campo);
  141.     end;
  142.    
  143.     txtTemp := '<td valign="TOP" bgcolor="#FFFFFF"><div align="right"><strong><font size="1" face="Verdana, Arial, Helvetica, sans-serif">';
  144.     PosIni := pos(txtTemp, SubLine);
  145.     if PosIni > 0 then
  146.     begin
  147.       txtAux := Copy(SubLine, PosIni + Length(txtTemp), Length(SubLine));
  148.       PosFin := pos(':', txtAux);
  149.       campo := Copy(txtAux, 1, PosFin - 1);
  150.  
  151.       LineNr := LineNr + 2;
  152.       SubLine := Page.GetString(LineNr);
  153.       txtTemp := '<td valign="TOP" bgcolor="#F5F5F5"><font size="1" face="Verdana, Arial, Helvetica, sans-serif">';
  154.       PosIni := pos(txtTemp, SubLine);
  155.       txtAux := Copy(SubLine, PosIni + Length(txtTemp), Length(SubLine));
  156.       PosFin := pos('</font></td>', txtAux);
  157.       valor := Copy(txtAux, 1, PosFin - 1);
  158.  
  159.       if campo = 'AÑO' then SetField(fieldYear, valor);
  160.       if campo = 'NACIONALIDAD' then SetField(fieldCountry, valor);
  161.       if campo = 'DIRECTOR' then SetField(fieldDirector, valor);
  162.       if campo = 'INTÉRPRETES' then SetField(fieldActors, valor);
  163.  
  164.       if campo = 'DURACION' then Comentarios := Comentarios + 'Duraci≤n: ' + valor + #13#10;
  165.       if campo = 'GUIÓN' then Comentarios := Comentarios + 'Gui≤n: ' + valor + #13#10;
  166.       if campo = 'FOTOGRAFÍA' then Comentarios := Comentarios + 'Fotografφa: ' + valor + #13#10;
  167.       if campo = 'MÚSICA' then Comentarios := Comentarios + 'M·sica: ' + valor + #13#10;
  168.  
  169.       //ShowMessage(campo + '-->' + valor);
  170.     end;
  171.    
  172.     txtTemp := '/cpp/albums/userpics/';
  173.     PosIni := pos(txtTemp, SubLine);
  174.     if PosIni > 0 then
  175.     begin
  176.       txtAux := Copy(SubLine, PosIni, Length(SubLine));
  177.       PosFin := pos('" width="', txtAux);
  178.       campo := Copy(txtAux, 1, PosFin - 1);
  179.       if Imagen = '' then Imagen := Base + campo;
  180.     end;
  181. //this is the other directory I found
  182.     txtTemp := '/c/';
  183.     PosIni := pos(txtTemp, SubLine);
  184.     if ((PosIni > 0) and (Imagen = '')) then
  185.     begin
  186.       txtAux := Copy(SubLine, PosIni, Length(SubLine));
  187.       PosFin := pos('" width="', txtAux);
  188.       campo := Copy(txtAux, 1, PosFin - 1);
  189.       if Imagen = '' then Imagen := Base + campo;
  190.     end;
  191.    
  192.     txtTemp := '<td valign="TOP" colspan="2"><font size="1" face="Arial, Helvetica, sans-serif">';
  193.     PosIni := pos(txtTemp, SubLine);
  194.     if PosIni > 0 then
  195.     begin
  196.       txtAux := Copy(SubLine, PosIni + Length(txtTemp), Length(SubLine));
  197.       PosFin := pos('</font></td>', txtAux);
  198.       campo := Copy(txtAux, 1, PosFin - 1);
  199.       if campo <> '' then SetField(fieldDescription, campo);
  200.     end;
  201.    
  202.     LineNr := LineNr + 1;
  203.   end;
  204.  
  205.   if Comentarios <> '' then SetField(fieldComments, Comentarios);
  206.   if Imagen <> '' then GetPicture(Imagen, False);
  207.  
  208.   Page.Free;
  209.   DisplayResults;
  210. end;
  211.  
  212. // bmicmic: Bucle Principal
  213. begin
  214.   if CheckVersion(3,4,0) then
  215.   begin
  216.     MovieName := GetField(fieldOriginalTitle);
  217.     if MovieName = '' then
  218.       MovieName := GetField(fieldTranslatedTitle);
  219.     Input('Importar de Carteles.Metropoli', 'Introduce el Titulo de la Pelicula:', MovieName);
  220.     AnalyzePage(BaseURL + UrlEncode(MovieName) + BaseURL2);
  221.    
  222.   end else
  223.        ShowMessage('Este script necesita una versi≤n superior de Ant Movie Catalog (al menos la version 3.4.0)');
  224. end.
  225.